package com.nbstar.film.spider;


import com.nbstar.film.spider.domain.FilmSpiderDomain;
import com.nbstar.film.spider.engine.*;
import com.nbstar.film.spider.excel.*;
import com.nbstar.film.spider.pojo.*;


import com.nbstar.film.spider.spider.*;
import com.nbstar.film.spider.thread.SpiderRequestThread;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.*;
import java.util.List;
import java.util.concurrent.*;

@Slf4j
public class Main {

    //private static Logger logger = LoggerFactory.getLogger(Main.class);


    public static void startYN() throws IOException {
        BaseSpiderEngine engine = new YNSpiderEngine();
        //engine.setReadExcelPath("E:\\运营开发\\湖北送审片单.xlsx");
        //engine.setReadExcelPath("E:\\运营开发\\hubei-fail.xlsx");
        engine.setReadExcelPath("E:\\运营开发\\四川咪咕在线免费电影（爬虫评分）20210119.xlsx");
        //engine.setReadExcelSheetIndex(0);//电影
        engine.setReadExcelSheetIndex(0);//电视剧
        engine.setReadExcelStartRow(3);
        ((YNSpiderEngine) engine).setReadExcelCol(0);
        //engine.setRetry(2);

        engine.setResultExcelName("E:\\运营开发\\四川-FILM-20210121.xlsx");
        engine.setResultSheetName("电影");
        engine.setThreadNum(5);

        //((YNSpiderEngine) engine).setType(TVCatSpider.MediaType.TV);
        log.debug("云南数据解析引擎启动....");
        engine.start();
    }

    public static void startSC() throws IOException {
        BaseSpiderEngine engine = new SCSpiderEngine();
        engine.setReadExcelPath("E:\\运营开发\\需要跑的内容20210603(1)(1).xlsx");
        //engine.setReadExcelPath("E:\\运营开发\\（已剔重）502部好莱坞影片0125(1)");
        //engine.setReadExcelPath("E:\\运营开发\\sichuan-film-0917 -maoyan.xlsx");
        engine.setReadExcelSheetIndex(0);
        engine.setReadExcelStartRow(1);
        engine.setRetry(1);
        ((SCSpiderEngine) engine).setFilm(true);

        engine.setResultExcelName("E:\\运营开发\\neimeng-tv-0607.xlsx");
        engine.setResultSheetName("film");
        engine.setThreadNum(5);

        engine.start();
    }

    public static void startSCV2() throws IOException {
        BaseSpiderEngine engine = new SCSpiderEngineV2();
        engine.setReadExcelPath("E:\\运营开发\\123.xlsx");
        //engine.setReadExcelPath("E:\\运营开发\\sichuan-film-0917 -maoyan.xlsx");
        engine.setReadExcelSheetIndex(0);
        ((SCSpiderEngineV2) engine).setNameIndex(0);
        engine.setReadExcelStartRow(1);
        ((SCSpiderEngineV2) engine).setSeqIndex(0);
        engine.setRetry(1);
        ((SCSpiderEngine) engine).setFilm(true);

        engine.setResultExcelName("E:\\运营开发\\sichuan-film-0126-2.xlsx");
        engine.setResultSheetName("film");
        engine.setThreadNum(5);

        engine.start();
    }

    /**
     * 少儿引擎
     * @throws IOException
     */
    public static void startSE() throws IOException {
        BaseSpiderEngine engine = new ShaoErEngine();
        //engine.setReadExcelPath("E:\\运营开发\\有版权号的数据表.xlsx");
        engine.setReadExcelPath("E:\\运营开发\\四川咪咕在线免费电影（爬虫评分）20210119.xlsx");
        //engine.setReadExcelPath("E:\\运营开发\\sichuan-film-0917 -maoyan.xlsx");
        engine.setReadExcelSheetIndex(0);
        engine.setReadExcelStartRow(2);
        engine.setRetry(1);

        engine.setResultExcelName("E:\\运营开发\\sichuan-FILM-20210121.xlsx");
        engine.setResultSheetName("电影");
        engine.setThreadNum(5);

        engine.start();
    }

    public static void startCC() throws IOException {
        BaseSpiderEngine engine = new CommonWebEngine();
        //engine.setReadExcelPath("E:\\运营开发\\sc01.xlsx");
        engine.setReadExcelPath("E:\\运营开发\\（已剔重）502部好莱坞影片0125(1).xlsx");
        engine.setReadExcelSheetIndex(0);
        engine.setReadExcelStartRow(3);
        ((CommonWebEngine) engine).setImdbIndex(13);
        ((CommonWebEngine)engine).setColIndex(0);

        engine.setResultExcelName("E:\\运营开发\\imdb-film-result-1.xlsx");
        engine.setResultSheetName("电影");
        ((CommonWebEngine) engine).setSpiderType(FilmSpiderDomain.SPIDER_FROM_IMDB);
        engine.setThreadNum(5);

        engine.start();
    }


    public static void startWhole() throws IOException {
        BaseSpiderEngine engine = new WholeSpiderEngine();
        //engine.setReadExcelPath("E:\\运营开发\\sc01.xlsx");
        engine.setReadExcelPath("E:\\运营开发\\内蒙IPTV需要跑的内容20210624.xlsx");
        engine.setReadExcelSheetIndex(0);
        engine.setReadExcelStartRow(1);
        ((WholeSpiderEngine) engine).setReadSeqNo(true);
        ((WholeSpiderEngine) engine).setSeqNoIndex(0);
        ((WholeSpiderEngine) engine).setReadCoyright(true);
        ((WholeSpiderEngine) engine).setCopyRightIndex(3);

        ((WholeSpiderEngine)engine).setColIndex(1);

        engine.setResultExcelName("E:\\运营开发\\whole-result-4.xlsx");
        engine.setResultSheetName("电影");
        engine.setThreadNum(5);

        engine.start();
    }

    public static void main(String[] args) throws IOException {
        //startSCV2();
        //startSE();
        //startYN();
        //startSC();
        //startCC();
        startWhole();
        //loadSiChuanExcel("E:\\运营开发\\001.xlsx", 0, 3);
        //loadYunNanExcel("E:\\运营开发\\云南注入内容片单.xlsx", 1, 1);
        //loadYunNanExcel("E:\\运营开发\\云南retry.xlsx", 0, 1);
        //createSpiderThread(1, "result", "E:\\运营开发\\spider-result.xlsx");
        //createYNSpiderThread(100, "电视剧", "E:\\运营开发\\YunNan-电视剧.xlsx", TVCatSpider.MediaType.TV);
        System.out.println("Ok!");



    }
}
